{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name=ABC, id=1, score=90\n",
      "name=XYZ, id=2, score=85\n",
      "name=JKL, id=3, score=95\n"
     ]
    }
   ],
   "source": [
    "students = [\n",
    "    (1, 'ABC', 90),\n",
    "    (2, 'XYZ', 85),\n",
    "    (3, 'JKL', 95)\n",
    "]\n",
    "\n",
    "for s in students:\n",
    "    print('name={}, id={}, score={}'.format(\n",
    "        s[1], s[0], s[2]\n",
    "    ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import collections\n",
    "\n",
    "Student = collections.namedtuple('Student', 'id, name, score')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "students = [\n",
    "    Student(1, 'ABC', 90),\n",
    "    Student(2, 'XYZ', 85),\n",
    "    Student(3, 'JKL', 95)\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Student(id=1, name='ABC', score=90),\n",
       " Student(id=2, name='XYZ', score=85),\n",
       " Student(id=3, name='JKL', score=95)]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "students"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name=ABC, id=1, score=90\n",
      "name=XYZ, id=2, score=85\n",
      "name=JKL, id=3, score=95\n"
     ]
    }
   ],
   "source": [
    "for s in students:\n",
    "    print('name={}, id={}, score={}'.format(\n",
    "        s[1], s.id, s[2]\n",
    "    ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
